package sf.dao.impl;

import java.util.List;
import java.util.Set;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import sf.dao.inf.EmailFileInf;
import sf.dao.pojo.TEmail;
import sf.dao.pojo.TEmailFile;

public class EmailFileImpl extends HibernateDaoSupport implements EmailFileInf {

	public void addFile(TEmailFile tEmailFile) {
//		try {
			getHibernateTemplate().save(tEmailFile);
//			getSession().beginTransaction().commit();
//		} catch (Exception e) {
//			e.printStackTrace();
//			getSession().beginTransaction().rollback();
//
//		}
		
		
	}

	public void deleteFile(int nemailid) {
		String hql = "from TEmailFile where nemailid = " + nemailid;
		List<TEmailFile> emailFiles = getHibernateTemplate().find(hql);
		for (TEmailFile tEmailFile : emailFiles) {
			getHibernateTemplate().delete(tEmailFile);
		}
	}

	public List<TEmailFile> showFiles(int nemailid) {
		String hql = "from TEmailFile where nemailid = " + nemailid;
		List<TEmailFile> emailFiles = getHibernateTemplate().find(hql);
		return emailFiles;
	}


}
